package finance

import org.apache.commons.math.stat.descriptive.DescriptiveStatistics

class DescriptiveStatisticsService {
    
    static transactional = true
    def stats 
    
    def addValues(doublesList) {
        stats = new DescriptiveStatistics()
        doublesList.each {  stats.addValue(it) }
    }
    
    def stats(doubles) {
        def map = [:]
        addValues(doubles)
        map["mean"] = stats.getMean() 
        map["stddev"] = stats.getStandardDeviation()
        map["kurtosis"] = stats.getKurtosis()
        map["skewness"] = stats.getSkewness()
        map["max"] = stats.getMax()
        map["min"] = stats.getMin()
        
        return map
    }
}
